﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="usrCarQuote.ascx.cs" Inherits="controls_usrCarQuote" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<script type="text/javascript">
    // Load the SDK Asynchronously
    (function(d) {
        var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
        if (d.getElementById(id)) { return; }
        js = d.createElement('script'); js.id = id; js.async = true;
        js.src = "//connect.facebook.net/en_US/all.js";
        ref.parentNode.insertBefore(js, ref);
    } (document));

    // Init the SDK upon load
    window.fbAsyncInit = function() {
        FB.init({
            appId: '588487661283699', // App ID
            channelUrl: '//' + window.location.hostname + '/channel', // Path to your Channel File
            status: true, // check login status
            cookie: true, // enable cookies to allow the server to access the session
            xfbml: true  // parse XFBML
        });
    }

    function userLogin() {
        FB.login(function(response) {
            if (response.authResponse) {
                // user has auth'd your app and is logged into Facebook
                var access_token = response.authResponse.accessToken;
                FB.api('/me?fields=id,name,email,first_name,last_name,gender,birthday,relationship_status', function(me) {
                    if (me.name) {
                        //parent.$.fancybox.close();
                        document.getElementById('<%= hiddenFacebookName.ClientID %>').value = me.name;
                        document.getElementById('<%= hiddenFacebookEmail.ClientID %>').value = me.email;
                        document.getElementById('<%= hiddenFacebookID.ClientID %>').value = me.id;

                        var a = document.getElementById("<%= lkFacebookLogin.ClientID %>");
                        var evObj = document.createEvent('MouseEvents');
                        evObj.initMouseEvent('click', true, true, window, 0, 0, 0, 1, 1, false, false, false, false, 0, null);
                        a.dispatchEvent(evObj);
                    }
                })
            } else {
                // user has not auth'd your app, or is not logged into Facebook
            }
        }, { scope: 'email,user_birthday,user_relationships' });
    }
</script>

<asp:UpdateProgress AssociatedUpdatePanelID="" ID="updateProgress" DynamicLayout="false"
    DisplayAfter="0" runat="server">
    <ProgressTemplate>
        <div class="loading-container">
            <img src="/images/loader/loader-yellow.gif" width="66" height="66" alt="" /></div>
    </ProgressTemplate>
</asp:UpdateProgress>
<div id="divLoading" class="loading-container">
    <img src="/images/loader/loader-yellow.gif" width="66" height="66" alt="" /></div>
<div class="radius-box-partner-quote">
    <div class="dbd-oic-col">
        <div class="steps-box-outline top10">
            <div class="brand-logo">
                <div id="divMotorBrand" runat="server" class="gluaygluay">
                </div>
            </div>
            <div class="steps-tx">
                <div class="steps-amount">
                    <div class="tx-no">
                        <span class="tx-quotes">
                            <%=GetGlobalResourceObject("General", "CQQuotes1")%>
                        </span>
                        <asp:Label ID="lblQuotes" runat="server"></asp:Label>
                        <span class="tx-quotes">
                            <%=GetGlobalResourceObject("General", "CQQuotes2")%>
                        </span>
                    </div>
                    <div class="tx-bold top10">
                        <asp:Label ID="lbl30Days" runat="server"></asp:Label>
                        <asp:Label ID="lblQuoteCar" runat="server" Visible="false"></asp:Label></div>
                </div>
                <div>
                    <asp:Image ID="ImgQuoteGet" runat="server" ImageUrl="<%$ Resources:ImageResource,ImgQuoteGet%>"
                        Width="<%$ Resources:ImageResource,ImgQuoteGetSize%>" Height="79" alt="" /></div>
            </div>
        </div>
        <div style="float: left; margin-top: 10px;">
            <img src="<%=GetGlobalResourceObject("ImageResource", "ImgPartnerDBDOICUrl")%>" width="280"
                height="76" alt="" /></div>
        <div style="float: left; margin-top: 15px; margin-left: 22px;">
            <!--- Secure Site Seal - DO NOT EDIT --->
            <span id="ss_img_wrapper_115-55_image_en"><a href="http://www.alphassl.com/ssl-certificates/wildcard-ssl.html"
                target="_blank" title="SSL Certificates">
                <img alt="Wildcard SSL Certificates" border="0" id="ss_img" src="//seal.alphassl.com/SiteSeal/images/alpha_noscript_115-55_en.gif"
                    title="SSL Certificate"></a></span><script type="text/javascript" src="//seal.alphassl.com/SiteSeal/alpha_image_115-55_en.js"></script><script
                        type="text/javascript" src="//seal.alphassl.com/SiteSeal/alpha_image_115-55_en.js"></script>

            <!--- Secure Site Seal - DO NOT EDIT --->
        </div>
    </div>
    <div class="form-col-3">
        <div class="main-title-heading">
            <%=GetGlobalResourceObject("General","GetCarQuotes") %></div>
        <asp:UpdatePanel ID="upnlCarDetails" runat="server">
            <ContentTemplate>
                <div style="width: 310px;">
                    <asp:Label ID="lblMessage" runat="server"></asp:Label>
                    <asp:ValidationSummary ID="vsCarDetails" runat="server" ValidationGroup="carquote"
                        ShowSummary="True" HeaderText="<%$ Resources:General,RequiredValidation%>" CssClass="error-msg" />
                </div>
                <div class="promo-row">
                    <asp:DropDownList ID="ddlManufactYear" runat="server" CssClass="input-fields-dropdown">
                        <asp:ListItem Text="<%$Resources:General,SelectCarYear%>" Value="-1" />
                    </asp:DropDownList>
                    <asp:RequiredFieldValidator ID="rfvManufactYear" ControlToValidate="ddlManufactYear"
                        CssClass="validationError" runat="server" ValidationGroup="carquote" ErrorMessage=""
                        InitialValue="-1"></asp:RequiredFieldValidator>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
        <div class="promo-row">
            <asp:DropDownList ID="ddlCarMake" runat="server" CssClass="input-fields-dropdown">
                <asp:ListItem Text="<%$Resources:General,SelectCarMake%>" Value="-1" />
            </asp:DropDownList>
            <input type="text" id="hidCarMake" runat="server" style="display: none;" value="-1" />
            <input type="text" id="hidCarMakeName" runat="server" style="display: none;" value="" />
            <asp:RequiredFieldValidator ID="rfvCarMake" ControlToValidate="hidCarMake" runat="server"
                CssClass="validationError" ValidationGroup="carquote" ErrorMessage="" InitialValue="-1"></asp:RequiredFieldValidator>
        </div>
        <div class="promo-row">
            <asp:DropDownList ID="ddlModelBodyCCDoor" runat="server" CssClass="input-fields-dropdown">
                <asp:ListItem Text="<%$Resources:General,SelectCarModel%>" Value="-1" />
            </asp:DropDownList>
            <input type="text" id="hidModelBodyCCDoor" runat="server" style="display: none;"
                value="-1" />
            <input type="text" id="hidModelBodyCCDoorName" runat="server" style="display: none;"
                value="" />
            <asp:RequiredFieldValidator ID="rfvModelBodyCCDoor" ControlToValidate="hidModelBodyCCDoor"
                CssClass="validationError" runat="server" ValidationGroup="carquote" ErrorMessage=""
                InitialValue="-1"></asp:RequiredFieldValidator>
            <asp:Label Visible="false" runat="server" ID="lblModelDesc" />
            <asp:Label runat="server" ID="lblCarVehicleType" Text="" Visible="false" />
            <div style="display: none;">
                <asp:Label runat="server" ID="lblSumInsured" Text="0" Visible="false" />
                <asp:TextBox ID="txtSumInsured" Visible="false" MaxLength="9" Width="80px" runat="server" />
                <asp:TextBox ID="txtNewSumInsured" Visible="false" MaxLength="9" Width="80px" runat="server" />
                <asp:TextBox ID="txtGroupNo" Visible="false" Text="-1" MaxLength="2" Width="30px"
                    runat="server" />
            </div>
        </div>
        <asp:UpdatePanel ID="UpdatePanel2" runat="server">
            <ContentTemplate>
                <div class="promo-row">
                    <div style="float: right; padding-right: 5px;">
                        <asp:Button ID="btnGetaQuote" Text="<%$ Resources:Home,GetQuote%>" runat="server"
                            Width="180" CssClass="action-button" OnClick="btnGetaQuote_Click" OnClientClick="LoadValidationErrorCss();CheckOptionValidationCss();CheckCookie();if (Page_ClientValidate('carquote')){this.removeAttribute('onmouseout');this.removeAttribute('onmouseup');this.className = 'action-button-processing';}"
                            ToolTip="<%$ Resources:Home,GetQuote%>" ValidationGroup="carquote" /></div>
                    <div style="float: right; padding-top: 10px; font-size: 12px; width: 100%;">
                        <%=GetGlobalResourceObject("CarInsurance", "RedPlateCallBack")%>
                        <asp:HyperLink ID="hplCallforDiscount" runat="server"><%=GetGlobalResourceObject("CarInsurance", "ClickHere")%></asp:HyperLink>
                    </div>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    <div class="car-col top20" style="display: none;">
        <div id="divCarQuoteNormal" runat="server" visible="true">
            <div class="steps-bg">
                <div class="steps-title ">
                    <asp:Label ID="lblInteractMessageHeader" runat="server"></asp:Label>
                </div>
                <div class="steps-box">
                    <div class="year-grey" id="divInteractCarYear" runat="server">
                        <asp:Label ID="lblInteractCarYear" runat="server" Text="<%$ Resources:General,Year%>"></asp:Label></div>
                    <div class="car-brand-tab" id="divInteractCarBrand" runat="server">
                        <div class="car-brand-grey" id="divInteractCarBrandInner1" runat="server">
                            <asp:Label ID="lblInteractCarBrand" runat="server" Text="<%$ Resources:General,CQCarMake%>"></asp:Label></div>
                        <div class="amount-grey" id="divInteractCarBrandInner2" runat="server">
                            <asp:Label ID="lblInteractMatches" runat="server"></asp:Label></div>
                    </div>
                    <div class="car-model" id="divInteractMessage" runat="server" style="visibility: hidden;">
                        <asp:Label ID="lblInteractMessage" runat="server"></asp:Label></div>
                </div>
                <div class="steps-box" style="display: none;">
                    <asp:Label ID="lblSteps" runat="server"></asp:Label>
                </div>
            </div>
        </div>
    </div>
</div>
<div>
    <asp:HiddenField runat="server" ID="hdnIsPromo" Value="0" />
    <asp:HiddenField runat="server" ID="hdnURLFrom" Value="" />
    <div>
        <cc1:ModalPopupExtender ID="mpeUserLogin" runat="server" TargetControlID="lnkbtnSignin"
            PopupControlID="pnModelPopup" BehaviorID="behCallMepop" DropShadow="false" CancelControlID="btnCancel"
            BackgroundCssClass="simplemodal-overlay">
        </cc1:ModalPopupExtender>
        <asp:Panel ID="pnModelPopup" runat="server" Style="display: none;">
            <!-- modal content -->
            <div id="simplemodal-container">
                <%--<div id="basic-modal-content">--%>
                <div class="pop-col">
                    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                        <ContentTemplate>
                            <div class=" text-heading-black">
                                <%=GetGlobalResourceObject("General", "EnterDetails")%>
                            </div>
                            <div>
                                <asp:Label ID="lblCarModelName" runat="server"></asp:Label><br />
                            </div>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                    <div style="width: 440px; height: 30px;">
                        <asp:ValidationSummary ID="vsUserDetails" runat="server" ValidationGroup="userlogin"
                            ShowSummary="True" HeaderText="<%$ Resources:General,RequiredValidation%>" CssClass="error-msg" />
                        <br />
                    </div>
                    <div class="cb-box">
                        <asp:UpdatePanel ID="upnlUserLogindetails" runat="server">
                            <ContentTemplate>
                                <div class="cb-row-1">
                                    <asp:Label ID="Label1" runat="server" Text="<%$ Resources:CarInsurance,Name%>" />:</div>
                                <div class="cb-col-1">
                                    <asp:TextBox ID="txtUserName" CssClass="cb-fields" runat="server" MaxLength="100"></asp:TextBox>
                                    <cc1:TextBoxWatermarkExtender ID="tbwUserName" runat="server" TargetControlID="txtUserName"
                                        WatermarkCssClass="cb-fields" WatermarkText="<%$Resources:General,EnterName%>">
                                    </cc1:TextBoxWatermarkExtender>
                                    <asp:RequiredFieldValidator ID="rfvUserName" runat="server" Text="" CssClass="validationError"
                                        ValidationGroup="userlogin" ErrorMessage="" ControlToValidate="txtUserName" Display="Dynamic"></asp:RequiredFieldValidator>
                                    <asp:RegularExpressionValidator ID="revUserName" Text="" CssClass="validationError"
                                        runat="server" ValidationGroup="userlogin" ErrorMessage="" ControlToValidate="txtUserName"
                                        ValidationExpression="^[\p{L}\d]*[^#$%^&*():/\.'^<>]*$" Display="Dynamic"></asp:RegularExpressionValidator>
                                </div>
                                <div class="cb-row-1">
                                    <asp:Label ID="lblUserEmail" runat="server" Text="<%$ Resources:CarInsurance,EmailAddress%>" />:</div>
                                <div class="cb-col-1">
                                    <asp:TextBox ID="txtUserEmail" CssClass="cb-fields" runat="server" MaxLength="100"></asp:TextBox>
                                    <div style="float: right; margin-top: 7px;">
                                        <a id="A2" runat="server" class="tooltips2">
                                            <img src="/images/lock.png" alt="ssl" width="25" height="25" /></a>
                                    </div>
                                    <cc1:TextBoxWatermarkExtender ID="tbwUserEmail" runat="server" TargetControlID="txtUserEmail"
                                        WatermarkCssClass="cb-fields" WatermarkText="<%$Resources:General,EnterEmail%>">
                                    </cc1:TextBoxWatermarkExtender>
                                    <asp:RequiredFieldValidator ID="rfvUserEmail" runat="server" Text="" CssClass="validationError"
                                        ValidationGroup="userlogin" ErrorMessage="" ControlToValidate="txtUserEmail"
                                        Display="Dynamic"></asp:RequiredFieldValidator>
                                    <asp:RegularExpressionValidator ID="revUserEmail" Text="" CssClass="validationError"
                                        runat="server" ValidationGroup="userlogin" ErrorMessage="" ControlToValidate="txtUserEmail"
                                        ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" Display="Dynamic"></asp:RegularExpressionValidator>
                                </div>
                                <div class="cb-row-1">
                                    <asp:Label ID="lblUserMobileNo" runat="server" Text="<%$ Resources:CarInsurance,MobileNo%>" />:</div>
                                <div class="cb-col-1">
                                    <asp:TextBox runat="server" ID="txtUserMobile" CssClass="cb-fields" MaxLength="10"></asp:TextBox>
                                    <input type="text" id="hidUserMobile" runat="server" style="display: none;" value="" />
                                    <div style="float: right; margin-top: 7px;">
                                        <a id="A1" runat="server" class="tooltips2">
                                            <img src="/images/lock.png" alt="ssl" width="25" height="25" /></a>
                                    </div>
                                    <cc1:TextBoxWatermarkExtender ID="tbwUserMobile" runat="server" TargetControlID="txtUserMobile"
                                        WatermarkCssClass="cb-fields" WatermarkText="<%$Resources:General,MobileExample%>">
                                    </cc1:TextBoxWatermarkExtender>
                                    <asp:RequiredFieldValidator ID="rfvUserMobile" runat="server" ControlToValidate="txtUserMobile"
                                        CssClass="validationError" Display="Dynamic" ErrorMessage="" ValidationGroup="userlogin"></asp:RequiredFieldValidator>
                                    <asp:RegularExpressionValidator ID="revUserMobile" runat="server" ControlToValidate="txtUserMobile"
                                        CssClass="validationError" ErrorMessage="" ValidationExpression="0[5-9]\d{8}"
                                        ValidationGroup="userlogin"></asp:RegularExpressionValidator>
                                </div>
                                <%--<div style="padding-left: 145px; padding-bottom: 10px; font-size: 11px; text-align: left;">
                                            <%=GetGlobalResourceObject("General", "MobileExample")%></div>--%>
                                <div class="cb-row-full">
                                    <asp:CheckBox ID="checkIsAgreement" runat="server" onclick="CheckedChanged();" />
                                    <asp:Label ID="lblAgreement" runat="server" Text="<%$ Resources:General,Agreement%>"
                                        CssClass="check-agree-text"></asp:Label>
                                    <asp:RequiredFieldValidator ID="rfvIsAccept" runat="server" ControlToValidate="txtIsAccept"
                                        CssClass="validationError" Display="Dynamic" ErrorMessage="" ValidationGroup="userlogin"></asp:RequiredFieldValidator>
                                    <div style="display: none;">
                                        <asp:TextBox ID="txtIsAccept" runat="server"></asp:TextBox>
                                    </div>
                                </div>
                                <div class="cb-row-full">
                                    <div>
                                        <asp:Button ID="btnViewResultsNow" ValidationGroup="userlogin" Text="<%$Resources:General,ViewResults%>"
                                            Width="200" runat="server" CssClass="action-button" OnClick="btnViewResultsNow_Click"
                                            OnClientClick="LoadValidationErrorCss(); CheckedChanged();if (Page_ClientValidate('userlogin')){this.removeAttribute('onmouseout');this.removeAttribute('onmouseup');this.className = 'action-button-processing';}" />
                                        <asp:HiddenField ID="hdnUserId" runat="server" Value="0" />
                                        <div id="divFacebookSignin" style="padding-top: 5px;">
                                            <asp:LinkButton ID="LinkButton1" runat="server" OnClientClick="userLogin(); return false;">
                                                <%--<img src='<%$ Resources:ImageResource,ImgLoginFB%>' alt="" width="180" height="35" style="padding-bottom:10px;" />--%>
                                                <asp:Image ID="imgFB" runat="server" AlternateText="" Width="180" Height="35" Style="padding-bottom: 10px;"
                                                    ImageUrl='<%$ Resources:ImageResource,ImgLoginFB%>' />
                                            </asp:LinkButton>
                                            <asp:LinkButton ID="lkFacebookLogin" runat="server" CausesValidation="false" OnClick="lkFacebookLogin_Click"
                                                Style="display: none;"></asp:LinkButton>
                                            <asp:HiddenField ID="hiddenFacebookName" runat="server" />
                                            <asp:HiddenField ID="hiddenFacebookEmail" runat="server" />
                                            <asp:HiddenField ID="hiddenFacebookID" runat="server" />
                                        </div>
                                    </div>
                                </div>
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </div>
                </div>
                <div class="pop-col-right-2">
                    <asp:UpdatePanel ID="upPopupResult" runat="server" Visible="true">
                        <ContentTemplate>
                            <div class="bubble-heading-2">
                                <span style="color: #cd0b00; font-size: 20px; font-weight: bold;">
                                    <asp:Label ID="lblResultCount" runat="server" Text="5"></asp:Label>
                                </span>
                                <asp:Label ID="lblPopupResultMessage1" runat="server" Text="<%$ Resources:CarInsurance,PopupResultMessage1%>"></asp:Label>
                                <br />
                                <asp:Label ID="lblPopupResultMessage2" runat="server" Text="<%$ Resources:CarInsurance,PopupResultMessage2%>"></asp:Label>
                                <span style="color: #cd0b00; font-size: 20px; font-weight: bold;">
                                    <asp:Label ID="lblInsurerCount" runat="server" Text="5"></asp:Label>
                                </span>
                                <asp:Label ID="lblPopupResultMessage3" runat="server" Text="<%$ Resources:CarInsurance,PopupResultMessage3%>"></asp:Label></div>
                        </ContentTemplate>
                    </asp:UpdatePanel>
                </div>
                <div style="float: right;">
                    <asp:ImageButton ID="btnCancel" runat="server" CssClass="modalCloseImg" ImageUrl="/images/close.png"
                        AlternateText="X" /></div>
            </div>
        </asp:Panel>
    </div>
    <div style="display: none;">
        <asp:LinkButton ID="lnkbtnSignin" runat="server" Text="Signin"></asp:LinkButton></div>
</div>

<script type="text/javascript">
    function CheckCookie() {

        if (readCookie("GGQuote") == null) {
            document.getElementById("<%=txtUserName.ClientID%>").className = "cb-fields";
            document.getElementById("<%=txtUserMobile.ClientID%>").className = "cb-fields";
            document.getElementById("<%=txtUserEmail.ClientID%>").className = "cb-fields";
        }
        else {
            document.getElementById("<%=txtUserName.ClientID%>").className = "cb-fields-disable";
            document.getElementById("<%=txtUserMobile.ClientID%>").className = "cb-fields-disable";
            document.getElementById("<%=txtUserEmail.ClientID%>").className = "cb-fields-disable";
        }
    }
    function readCookie(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for (var i = 0; i < ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) == ' ') c = c.substring(1, c.length);
            if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
        }
        return null;
    }

    function CheckedChanged() {
        var ctrlTxt = document.getElementById('<%=txtIsAccept.ClientID %>');
        var ctrlAgree = document.getElementById('<%=checkIsAgreement.ClientID %>');
        var lblAgree = document.getElementById('<%=lblAgreement.ClientID %>');
        ctrlTxt.value = '1';
        lblAgree.setAttribute("class", "check-agree-text");
        if (ctrlAgree.checked == false) {
            ctrlTxt.value = '';
            lblAgree.setAttribute("class", "check-agree-text validationError");
        }
    }
</script>

<script type="text/javascript">
    $(document).ready(function() {
        $('#divLoading').hide();
        $('#<%=ddlCarMake.ClientID %>').empty().append('<option value="-1">' + '<%=GetGlobalResourceObject("General", "SelectCarMake")%>' + '</option>');
        $('#<%=ddlModelBodyCCDoor.ClientID %>').empty().append('<option value="-1">' + '<%=GetGlobalResourceObject("General", "SelectCarModel")%>' + '</option>');
        var ispromo = $('#<%=hdnIsPromo.ClientID%>').val();
        if (ispromo == "1") {
            $('#simplemodal-container').css("background-image", "url(/images/cny-promo-bg.jpg)");
        }
        initUI();
    })
    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_endRequest(function() {
        initUI();
    });
    function initUI() {
        $('#<%=ddlManufactYear.ClientID %>').change(function() {
            $('#divLoading').show();

            //set value to hiddenfield
            $('#<%=hidCarMake.ClientID%>').val('-1');
            $('#<%=hidCarMakeName.ClientID%>').val('');

            $('#<%=hidModelBodyCCDoor.ClientID%>').val('-1');
            $('#<%=hidModelBodyCCDoorName.ClientID%>').val('');

            if ($(this).val() != "-1") {
                var selectedyear = $('#<%=ddlManufactYear.ClientID%>').val();
                var selectedcarmake = '-1';
                var selectedcarmodel = '-1';
                $('#<%=ddlModelBodyCCDoor.ClientID %>').empty().append('<option value="-1">' + '<%=GetGlobalResourceObject("General", "SelectCarModel")%>' + '</option>');
                $.ajax({
                    type: "POST",
                    url: '<%= ConfigurationManager.AppSettings["TH.HostName"].ToString()%>' + 'car-insurance/get-car-details.asmx/GetCarMakeList',
                    data: "{'Year':'" + selectedyear + "', 'CarMake': '" + selectedcarmake + "', 'CarModel': '" + selectedcarmodel + "'}",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function(msg) {
                        var j = jQuery.parseJSON(msg.d);
                        var options;
                        options = '<option value="-1">' + '<%=GetGlobalResourceObject("General", "SelectCarMake")%>' + '</option>';
                        for (var i = 0; i < j.length; i++) {
                            options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>'
                        }
                        $('#<%=ddlCarMake.ClientID %>').html(options);
                        $('#<%=lblQuotes.ClientID %>').text(j[0].quoteCount);
                        $('#<%=divMotorBrand.ClientID %>').removeClass().addClass(j[0].carBrand);

                        //set message
                        $('#<%=lblInteractMessageHeader.ClientID %>').text('');
                        $('#<%=lblInteractCarYear.ClientID %>').text($('#<%=ddlManufactYear.ClientID%>').val());
                        $('#<%=lblInteractCarBrand.ClientID %>').text('<%=GetGlobalResourceObject("General", "CQCarMake")%>');
                        $('#<%=lblInteractMatches.ClientID %>').html('<%=GetGlobalResourceObject("General", "CQFound")%>' + " <b>0</b> " + '<%=GetGlobalResourceObject("General", "CQMatches")%>');
                        $('#<%=divInteractCarYear.ClientID %>').removeClass().addClass('year');
                        $('#<%=divInteractCarBrandInner1.ClientID %>').removeClass().addClass('car-brand-grey');
                        $('#<%=divInteractCarBrandInner2.ClientID %>').removeClass().addClass('amount-grey');
                        $('#<%=lblInteractMatches.ClientID %>').removeAttr("style").css('margin-left', '0');

                        $('#divLoading').hide();
                    },
                    error: function(data) {
                        alert('Network connection failed. Please try again!')
                    }
                });
            }
            else {
                //set message
                $('#<%=ddlCarMake.ClientID %>').empty().append('<option value="-1">' + '<%=GetGlobalResourceObject("General", "SelectCarMake")%>' + '</option>');
                $('#<%=ddlModelBodyCCDoor.ClientID %>').empty().append('<option value="-1">' + '<%=GetGlobalResourceObject("General", "SelectCarModel")%>' + '</option>');

                $('#<%=lblInteractMessageHeader.ClientID %>').text('<%=GetGlobalResourceObject("General", "CQSelectCarYear")%>');
                $('#<%=lblInteractCarYear.ClientID %>').text('<%=GetGlobalResourceObject("General", "Year")%>');
                $('#<%=lblInteractCarBrand.ClientID %>').text('<%=GetGlobalResourceObject("General", "CQCarMake")%>');
                $('#<%=lblInteractMatches.ClientID %>').html('<%=GetGlobalResourceObject("General", "CQFound")%>' + " <b>0</b> " + '<%=GetGlobalResourceObject("General", "CQMatches")%>');
                $('#<%=lblInteractMessage.ClientID %>').text('');
                $('#<%=divInteractCarYear.ClientID %>').removeClass().addClass('year-grey');
                $('#<%=divInteractCarBrandInner1.ClientID %>').removeClass().addClass('car-brand-grey');
                $('#<%=divInteractCarBrandInner2.ClientID %>').removeClass().addClass('amount-grey');
                $('#<%=divInteractMessage.ClientID %>').removeAttr("style").css('visibility', 'hidden');
                $('#<%=lblInteractMatches.ClientID %>').removeAttr("style").css('margin-left', '0');

                $('#divLoading').hide();
            }
        });
    }
    $('#<%=ddlCarMake.ClientID %>').change(function() {
        $('#divLoading').show();

        //set value to hiddenfield
        $('#<%=hidModelBodyCCDoor.ClientID%>').val('-1');
        $('#<%=hidModelBodyCCDoorName.ClientID%>').val('');

        if ($(this).val() != "-1") {
            var selectedyear = $('#<%=ddlManufactYear.ClientID%>').val();
            var selectedcarmake = $('#<%=ddlCarMake.ClientID%>').val();
            var selectedcarmodel = $('#<%=ddlModelBodyCCDoor.ClientID%>').val();
            $.ajax({
                type: "POST",
                url: '<%= ConfigurationManager.AppSettings["TH.HostName"].ToString()%>' + 'car-insurance/get-car-details.asmx/GetCarModelDescList',
                data: "{'Year':'" + selectedyear + "', 'CarMake': '" + selectedcarmake + "', 'CarModel': '" + selectedcarmodel + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function(msg) {
                    var j = jQuery.parseJSON(msg.d);
                    var options;
                    options = '<option value="-1">' + '<%=GetGlobalResourceObject("General", "SelectCarModel")%>' + '</option>';
                    for (var i = 0; i < j.length; i++) {
                        options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>'
                    }
                    $('#<%=ddlModelBodyCCDoor.ClientID %>').html(options);
                    $('#<%=lblQuotes.ClientID %>').text(j[0].quoteCount);
                    $('#<%=divMotorBrand.ClientID %>').removeClass().addClass(j[0].carBrand);

                    //set value to hiddenfield
                    $('#<%=hidCarMake.ClientID%>').val($('#<%=ddlCarMake.ClientID%>').val());
                    var carmakename = $('#<%=ddlCarMake.ClientID%>' + ' option:selected').text();
                    $('#<%=hidCarMakeName.ClientID%>').val(carmakename);

                    $('#<%=ddlCarMake.ClientID%>').removeClass("validationError");

                    //set message
                    $('#<%=lblInteractCarBrand.ClientID %>').text($('#<%=ddlCarMake.ClientID%> option:selected').text());
                    $('#<%=lblInteractMatches.ClientID %>').html('<%=GetGlobalResourceObject("General", "CQFound")%>' + " <b>" + ($('#<%=ddlModelBodyCCDoor.ClientID%> option').size() - 1) + "</b> " + '<%=GetGlobalResourceObject("General", "CQMatches")%>');
                    $('#<%=lblInteractMessage.ClientID %>').text('');
                    $('#<%=divInteractCarBrandInner1.ClientID %>').removeClass().addClass('car-brand');
                    $('#<%=divInteractCarBrandInner2.ClientID %>').removeClass().addClass('amount');
                    $('#<%=lblInteractMatches.ClientID %>').removeAttr("style").css('margin-left', '0');

                    $('#divLoading').hide();
                },
                error: function(data) {
                    alert('Network connection failed. Please try again!')
                }
            });
        }
        else {
            //set value to hiddenfield
            $('#<%=hidCarMake.ClientID%>').val('-1');
            $('#<%=hidCarMakeName.ClientID%>').val('');

            //set message
            $('#<%=ddlModelBodyCCDoor.ClientID %>').empty().append('<option value="-1">' + '<%=GetGlobalResourceObject("General", "SelectCarModel")%>' + '</option>');

            $('#<%=lblInteractCarBrand.ClientID %>').text('<%=GetGlobalResourceObject("General", "CQCarMake")%>');
            $('#<%=lblInteractMatches.ClientID %>').html('<%=GetGlobalResourceObject("General", "CQFound")%>' + " <b>0</b> " + '<%=GetGlobalResourceObject("General", "CQMatches")%>');
            $('#<%=lblInteractMessage.ClientID %>').text('');
            $('#<%=divInteractCarBrandInner1.ClientID %>').removeClass().addClass('car-brand-grey');
            $('#<%=divInteractCarBrandInner2.ClientID %>').removeClass().addClass('amount-grey');
            $('#<%=divInteractMessage.ClientID %>').removeAttr("style").css('visibility', 'hidden');
            $('#<%=lblInteractMatches.ClientID %>').removeAttr("style").css('margin-left', '0');

            $('#divLoading').hide();
        }
    });
    $('#<%=ddlModelBodyCCDoor.ClientID %>').change(function() {

        if ($(this).val() != "-1") {
            var selectedcarmake = $('#<%=ddlCarMake.ClientID%>').val();
            var selectedcarmodel = $('#<%=ddlModelBodyCCDoor.ClientID%>').val();

            //set message
            var _strSelectedCarModel;
            var _strAutoMan = "";
            var _strSelectedCarModelSplit = $('#<%=ddlModelBodyCCDoor.ClientID%> option:selected').text().split(',');

            if (_strSelectedCarModelSplit.length == 5)
                _strSelectedCarModel = _strSelectedCarModelSplit[0] + "," + _strSelectedCarModelSplit[1];
            else
                _strSelectedCarModel = _strSelectedCarModelSplit[0];

            if (_strSelectedCarModel.search(" Auto ") != -1) {
                _strSelectedCarModel = _strSelectedCarModel.replace(" Auto ", " ");
                _strAutoMan = " <span style='font-size:80%;font-style: italic;'>(Auto)</span>";
            }
            else if (_strSelectedCarModel.search(" Man ") != -1) {
                _strSelectedCarModel = _strSelectedCarModel.replace(" Man ", " ");
                _strAutoMan = " <span style='font-size:80%;font-style: italic;'>(Manual)</span>";
            }
            _strSelectedCarModel = _strSelectedCarModel.replace("_", " ");

            $('#<%=divInteractMessage.ClientID %>').removeAttr("style").css('visibility', 'visible');
            $('#<%=lblInteractMessage.ClientID %>').html(_strSelectedCarModel + _strAutoMan);
            $('#<%=lblInteractMatches.ClientID %>').text('<%=GetGlobalResourceObject("General", "CQClickGetQuote")%>');
            $('#<%=lblInteractMatches.ClientID %>').removeAttr("style").css('margin-left', '-54px');

            //set value to hiddenfield
            $('#<%=hidModelBodyCCDoor.ClientID%>').val($('#<%=ddlModelBodyCCDoor.ClientID%>').val());
            var carmodelname = $('#<%=ddlModelBodyCCDoor.ClientID%>' + ' option:selected').text();
            $('#<%=hidModelBodyCCDoorName.ClientID%>').val(carmodelname);

            $('#<%=ddlModelBodyCCDoor.ClientID%>').removeClass("validationError");


            $.ajax({
                type: "POST",
                url: '<%= ConfigurationManager.AppSettings["TH.HostName"].ToString()%>' + 'car-insurance/get-car-details.asmx/GetCarQuoteCountLast30DaysByCarModel',
                data: "{'CarMake': '" + selectedcarmake + "', 'CarModel': '" + selectedcarmodel + "'}",
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function(msg) {
                    var j = jQuery.parseJSON(msg.d);
                    $('#<%=lblQuotes.ClientID %>').text(j[0].quoteCount);
                    $('#<%=divMotorBrand.ClientID %>').removeClass().addClass(j[0].carBrand);
                },
                error: function(data) {
                    alert('Network connection failed. Please try again!')
                }
            });
        }
        else {
            //set value to hiddenfield
            $('#<%=hidModelBodyCCDoor.ClientID%>').val('-1');
            $('#<%=hidModelBodyCCDoorName.ClientID%>').val('');

            //set message
            $('#<%=lblInteractMatches.ClientID %>').html('<%=GetGlobalResourceObject("General", "CQFound")%>' + " <b>" + ($('#<%=ddlModelBodyCCDoor.ClientID%> option').size() - 1) + "</b> " + '<%=GetGlobalResourceObject("General", "CQMatches")%>');
            $('#<%=lblInteractMessage.ClientID %>').text('');
            $('#<%=divInteractMessage.ClientID %>').removeAttr("style").css('visibility', 'hidden');
            $('#<%=lblInteractMatches.ClientID %>').removeAttr("style").css('margin-left', '0');


        }
    });

    function CheckOptionValidationCss() {
        if ($('#<%=hidCarMake.ClientID%>').val() == "-1") {
            $('#<%=ddlCarMake.ClientID%>').addClass("validationError");
        }
        if ($('#<%=hidModelBodyCCDoor.ClientID%>').val() == "-1") {
            $('#<%=ddlModelBodyCCDoor.ClientID%>').addClass("validationError");
        }
    }
</script>

